public class BubbleTest {

  public static void main(String[] args) {
    int i;
    int[] array = { 1, 5, 8, 3, 5, 10, 8, 7, 101, 78 };
    int[] result = bubbleSort(array);

    for (i = 0; i < result.length; i++) {
      System.out.print(result[i]);
      System.out.print(" ");
    }

    System.out.println();
  }

  private static int[] bubbleSort(int[] array) {
    int i, j, tmp;

    for (i = 0; i < array.length - 1; i++) {
      for (j = 0; j < array.length - i - 1; j++) {
        if (array[j] > array[j + 1]) {
          tmp = array[j];
          array[j] = array[j + 1];
          array[j + 1] = tmp;
        }
      }
    }

    return array;
  }
}
